/*
 * Copyright 2016-2021 the original author.All rights reserved.
 * Kingstar(aiteasoft@163.com)
 * The license,see the LICENSE file.
 */

package com.aiteasoft.school.stascore.rest;

import static com.automvc.common.service.CommService.hasNull;
import static com.automvc.common.service.CommService.isNullPara;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.teasoft.bee.osql.service.ObjSQLRichService;
import org.teasoft.bee.osql.service.ObjSQLService;

import com.automvc.common.jq.Result;

import com.aiteasoft.school.stascore.entity.StaScore;
import com.aiteasoft.school.stascore.service.StaScoreService;

/**
 * @author AiTeaSoft.com
 * @since  1.9
 * Create on 2021-01-29 18:14:40
 */
@RestController("staScore")
@RequestMapping("staScore")
public class StaScoreRest {  
	@Autowired
	ObjSQLService objSQLService;
	@Autowired
	ObjSQLRichService objSQLRichService;

	@Autowired
	StaScoreService staScoreService;

	@RequestMapping("/list")
	public Result list(StaScore staScore, 
			@RequestParam(value = "page", defaultValue = "1", required = false) int page,
			@RequestParam(value = "rows", defaultValue = "20", required = false) int rows
			) {

		Result result = new Result();
		if (isNullPara(result, staScore)) return result;
		
		staScore = staScoreService.process(staScore);
		int total = staScoreService.selectCount(staScore);
		List<StaScore> list = staScoreService.select(staScore, (page - 1) * rows, rows);
		
		result.setRows(list);
		result.setTotal(total);

		return result;
	}

}